# -*- coding: utf-8 -*-
#
# File: CFOMOAMOU.py
#
# Copyright (c) 2011 by unknown <unknown>
# Generator: ArchGenXML Version 2.6
#            http://plone.org/products/archgenxml
#
# GNU General Public License (GPL)
#

__author__ = """unknown <unknown>"""
__docformat__ = 'plaintext'

from AccessControl import ClassSecurityInfo
from Products.Archetypes.atapi import *
from zope.interface import implements
import interfaces

from Products.CMFDynamicViewFTI.browserdefault import BrowserDefaultMixin

from Products.CFOPloneDirectives.config import *

# additional imports from tagged value 'import'
from Products.PloneDirectives.content.MOAMOU import MOAMOU
from Products.PloneDirectives.content.MOAMOU import MOAMOU_schema
from Products.PloneDirectives.content.CFOPolicy import CFOPolicy_schema

##code-section module-header #fill in your manual code here
##/code-section module-header

copied_fields = {}
copied_fields['directiveOrg'] = CFOPolicy_schema['directiveOrg'].copy()
copied_fields['directiveSubOrg'] = CFOPolicy_schema['directiveSubOrg'].copy()
copied_fields['directiveOffice'] = MOAMOU_schema['directiveOffice'].copy()
copied_fields['directiveOffice'].default = ""
copied_fields['directiveOffice'].required = 0
copied_fields['directiveOffice'].widget.visible = 0
schema = Schema((

    copied_fields['directiveOrg'],

    copied_fields['directiveSubOrg'],

    copied_fields['directiveOffice'],


),
)

##code-section after-local-schema #fill in your manual code here
##/code-section after-local-schema

CFOMOAMOU_schema = MOAMOU_schema.copy() + \
    schema.copy()

##code-section after-schema #fill in your manual code here
CFOMOAMOU_schema.moveField('directiveSubOrg', after="directiveOrg")
##/code-section after-schema

class CFOMOAMOU(MOAMOU, BrowserDefaultMixin):
    """
    """
    security = ClassSecurityInfo()

    implements(interfaces.ICFOMOAMOU)

    meta_type = 'CFOMOAMOU'
    _at_rename_after_creation = True

    schema = CFOMOAMOU_schema

    ##code-section class-header #fill in your manual code here
    ##/code-section class-header

    # Methods

    # Manually created methods

    security.declarePublic('getDirectiveSubOrgVocab')
    def getDirectiveSubOrgVocab(self, master):
        """Vocab method that returns a vocabulary for the directiveSubOrg,
           based on what the user selected for directiveOrg.
        """
        vocabs = dict(self.getCFOPolicyDirectiveOrgVocabularies())
        results = vocabs[master]
        if not results: #if no sub orgs, provide a single choice of "None" instead of a blank drop-down
            results = ["None",]
        return DisplayList((result, result) for result in results)

    security.declarePublic('getCFOPolicyDefaultDirectiveOrgVocabulary')
    def getCFOPolicyDefaultDirectiveOrgVocabulary(self):
        """Returns a default vocabulary for directiveOrg
        """
        return [list[0] for list in self.getCFOPolicyDirectiveOrgVocabularies()]

    security.declarePublic('getCFOPolicyDefaultDirectiveSubOrgVocabulary')
    def getCFOPolicyDefaultDirectiveSubOrgVocabulary(self):
        """Returns a default vocabulary for directiveSubOrg
        """
        return [item for list in self.getCFOPolicyDirectiveOrgVocabularies() for item in list[1]]



registerType(CFOMOAMOU, PROJECTNAME)
# end of class CFOMOAMOU

##code-section module-footer #fill in your manual code here
##/code-section module-footer

